package modelo;

import utils.LevenshteinDistance;
import utils.StringFormatter;

public class Observacion
{
	private int id;
	private String atributo;
	private String valor;
	private String tipo;

	public Observacion()
	{
	}

	@Override
	public boolean equals(Object obj)
	{
		Observacion other = (Observacion) obj;
		if(!this.atributo.equals(other.getAtributo()))
			return false;
		if(!this.valor.equals(other.getValor()))
			return false;
		if(!this.tipo.equals(other.getTipo()))
			return false;
		return true;
	}

	public int getId()
	{
		return id;
	}

	public void setId(int id)
	{
		this.id = id;
	}

	public String getAtributo()
	{
		return atributo;
	}

	public void setAtributo(String atributo)
	{
		this.atributo = atributo;
	}

	public String getValor()
	{
		return valor;
	}

	public void setValor(String valor)
	{
		this.valor = valor;
	}

	public String getTipo()
	{
		return tipo;
	}

	public void setTipo(String tipo)
	{
		this.tipo = tipo;
	}

	public ObservacionView getView()
	{
		return new ObservacionView(atributo, valor, tipo);
	}

	public boolean atributoSimilar(String at)
	{
		String att1 = StringFormatter.format(this.atributo);
		String att2 = StringFormatter.format(at);

		boolean a = att1.startsWith(att2);
		boolean b = LevenshteinDistance.getCalculatedDistance(att1, att2) <= 0.10;

		return a || b;
	}

	public boolean valorSimilar(String v)
	{
		String v1 = StringFormatter.format(this.valor);
		String v2 = StringFormatter.format(v);

		boolean a = v1.startsWith(v2);
		boolean b = LevenshteinDistance.getCalculatedDistance(v1, v2) <= 0.10;

		return a || b;
	}
}